<?php include('include/entete.html'); ?>

<?php
	// Récupération de l'ID de l'emplacement
	$pays = $_GET['pays'];
?>

<br/><br/>
 
<div class="contenu">
	<table align="center" width="100%" cellpadding="3" cellspacing="0">
	<tr>
		<td id="cell1"><?php echo $pays; ?></td>
	</tr>
	<tr>
		<td id="cell2">

 
<br/>
<b>/<a href="index.php">Liste Pays</a></b>

<?php

	try {
		$db = new PDO('mysql:host=localhost;dbname=campingcar', 'root', '');
		//echo 'Connected to database';
    }
	catch(PDOException $e) {
		echo $e->getMessage();
    }
	
	$sql = "SELECT * FROM emplacement WHERE pays='".$pays."' ORDER BY localite";
	$select_messages = $db->prepare($sql);
	$select_messages->execute();
?>

<div class="table">
<table border="0" width="100%">
	<tr class="thead"
		<th>id</th>
		<th>type</th>
		<th>localite</th>
		<th>GPS (MapSource)</th>
	</tr>
<?php
	$couleur = array(0 => "ligne1", 1 => "ligne2");
	$i = 0;
	foreach($select_messages->fetchAll() as $rec) {
		echo '<tr class="'.$couleur[$i%2].'">';
		echo '<td>'.$rec['id'].'</td>';
		echo '<td>'.$rec['type_emplacement_id'].'</td>';
		echo '<td><a href="emplacement.php?pays='.$pays.'&id='.$rec['id'].'">'.$rec['localite'].'</a></td>';
		if (doubleval($rec['GPSE'])<0) {
			echo '<td>N'.doubleval($rec['GPSN']).' W'.abs(doubleval($rec['GPSE'])).'</td>';
		} else {
			echo '<td>N'.doubleval($rec['GPSN']).' E'.doubleval($rec['GPSE']).'</td>';
		}
		echo '</tr>';
		$i++;
	}
?>
</table>
</div>	
 
</td>
</tr>
</table>
</div>

<br/><br/>
 
<?php include('include/piedPage.html'); ?>
            
